/**
 * 该例程将执行/show_person服务，服务数据类型learning_service::Person
 */
 
#include <ros/ros.h>
#include "learning_service/Person.h"

// service回调函数，输入参数req，输出参数res
bool personCallback(learning_service::Person::Request  &req, learning_service::Person::Response &res){
    ROS_INFO("Person: name:%s  age:%d  sex:%d", req.name.c_str(), req.age, req.sex);// 显示请求数据
    res.result = "OK";// 设置反馈数据
    return true;
}

int main(int argc, char **argv){
    ros::init(argc, argv, "person_server");
    ros::NodeHandle n;
    ros::ServiceServer person_service = n.advertiseService("/show_person", personCallback);
    
    ROS_INFO("Ready to show person informtion.");// 循环等待回调函数
    ros::spin();
    return 0;
}


